//package com.woniuxy.microsysserver.serurity.security;
//
//import com.woniuxy.microsysserver.serurity.util.ResponseEntity;
//import com.woniuxy.microsysserver.serurity.util.ResponseUtil;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.logout.LogoutHandler;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///*
// * @author: masterhai
// * @date: 2021/3/2:17:26
// * @description:登出业务逻辑类
// */
//public class TokenLogoutHandler implements LogoutHandler {
//
//    private TokenManager tokenManager;
//    private RedisTemplate redisTemplate;
//
//    public TokenLogoutHandler(TokenManager tokenManager, RedisTemplate redisTemplate) {
//        this.tokenManager = tokenManager;
//        this.redisTemplate = redisTemplate;
//    }
//
//    @Override
//    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
//        String token = request.getHeader("token");
//        if (token != null) {
//            tokenManager.removeToken(token);
//
//            //清空当前用户缓存中的权限数据
//            String userName = tokenManager.getUserFromToken(token);
//            redisTemplate.delete(userName);
//        }
//        ResponseUtil.out(response, ResponseEntity.ok());
//    }
//
//}